#pragma once

#include "SRGLinc.h"
#include "SRData.h"
#include <map>

namespace sora
{
	class VertexBufferObject;
	class IndexBufferObject;
	class Texture;
	class TextureManager;
	class VBOManager;

	class Texture {
	public:
		Texture();
		virtual ~Texture();
		GLuint texId() const;
	protected:
		GLuint texId_;
	};

	class SampleTexture : public Texture {
	public:
		SampleTexture();
		virtual ~SampleTexture();
	};

	class TextureManager {
	public:
		static TextureManager& mgr();
		~TextureManager();

		//load..
		Texture *get(GLuint texId) const;
		void unloadOccur(GLuint texId);

	private:
		TextureManager();
		TextureManager(const TextureManager &o);
		TextureManager& operator=(const TextureManager &o);
		std::map<GLuint, Texture*> texMap_;
	};

	class BufferObjectManager {
	public:
		static BufferObjectManager& mgr();
		~BufferObjectManager();
	private:
		BufferObjectManager();
		BufferObjectManager(const BufferObjectManager &o);
		BufferObjectManager& operator=(const BufferObjectManager &o);
	};

	class VertexBufferObject {
	public:
		VertexBufferObject(const GLvoid *data, int count, GLsizei stride, GLenum usage);
		VertexBufferObject(const DrawCommand &cmd, GLenum usage);
		virtual ~VertexBufferObject();

		inline GLuint buffer() const { return buffer_; }
		inline int count() const { return count_; }
		inline GLsizei stride() const { return stride_; }
	private:
		GLuint buffer_;
		int count_;
		GLsizei stride_;
	};

	class IndexBufferObject {
	public:
		IndexBufferObject(const GLvoid *data, int count, GLenum indexType, GLenum drawMode, GLenum usage);
		IndexBufferObject(const DrawCommand &cmd, GLenum usage);
		virtual ~IndexBufferObject();

		inline GLuint buffer() const { return buffer_; }
		inline int count() const { return count_; }
		inline GLsizei stride() const { return stride_; }
		inline GLenum indexType() const { return indexType_; }
		inline GLenum drawMode() const { return drawMode_; }
	private:
		GLuint buffer_;
		int count_;
		GLsizei stride_;
		GLenum drawMode_;
		GLenum indexType_;
	};
}
